package com.axjy.yycg.mapper;

import com.axjy.yycg.pojo.Menu;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuMapper {

    @Select("select * from menu where p_Id=0")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "children", column = "id",
                    many = @Many(select = "findSecondMenus"))
    })
    public List<Menu> findFirstMenus();

    @Select("select * from menu where p_Id=#{pid}")
    public List<Menu> findSecondMenus(Integer pid);

    @Select("select * from menu where id=#{id}")
    public Menu get(Integer id);


}

